package org.totoro.concurrent.juc.collection;

import org.junit.Test;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author YHL
 * @version V1.0
 * @Description:
 * @date 2018-06-28
 */
public class ConcurrentHashMapTest {


    @Test
    public void test1() {

        /**
         * initialCapacity:
         * <pre>
         *     默认大小：16
         *
         *     总量大小，通过业务估算总量大小，来减少扩容。
         *
         * </pre>
         * loadFactor:
         *
         * <pre>
         *     默认值：0.75
         *
         *     负载因子，
         *
         * </pre>
         *
         *
         * 扩容：initialCapacity * loadFactor

         */
        ConcurrentHashMap<Integer, Object> objectObjectConcurrentHashMap = new ConcurrentHashMap<>(50, 0.75f);


        for (int i = 0; i < 50; i++) {
            objectObjectConcurrentHashMap.put(i, "");
        }

        objectObjectConcurrentHashMap.put(51,"");

        System.out.println(objectObjectConcurrentHashMap);


    }

}
